<?php
//__set 和 __get的用法

class Other{
    public $name='xiao';
    public $arr = [];


    public function __set($key,$value){
        var_dump(__METHOD__);
        $this->arr[$key] = $value;
    }

    public function __get($key){
        var_dump(__METHOD__);
        return $this->arr[$key];
    }

}

$class = new Other();
echo $class->name.'<hr>';

$class->age = 27;
echo $class->age.'<hr>';
